<template>
  <div id="index" style="overflow: hidden;overflow-y: auto;">
    <dl v-for="(item,i) in dataList" :key="i">
      <dt>{{item.name}}</dt>
      <dd v-for="(term,j) in item.list" :key="i*10+j">
        <p v-if="term.showM">
          <el-button type="primary" @click="intoAddress(term)" plain>{{term.name}}</el-button>
        </p>
      </dd>
    </dl>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dataList: [
        {
          name: "缴费系统初始化设置",
          list: [
            { name: "收款账户管理", showM:false, url:"CollectionAccountManagement",roles:["GroupManager","GroupFinance"]},
            { name: "缴费项目自定义设置", showM:false, url:"CustomSettings", roles:["GroupManager","GroupFinance"]},
            { name: "电子印章管理", showM:false, url:"ElectronicSealManagement", roles:["GroupManager","GroupFinance"] },
            { name: "新增编辑电子印章详情", showM:false, url:"ElectronicSealDetails", roles:["GroupManager","GroupFinance"]},
            { name: "冻结设置", showM:false, url:"FreezingSettings", roles:["GroupManager","GroupFinance"]},
            { name: "缴费方案", showM:false, url:"PaymentScheme", roles:["GroupManager","GroupFinance"]},
            { name: "缴费类型设置", showM:false, url:"PaymentTypeSetting", roles:["GroupManager","GroupFinance"]},
            { name: "操作日志", showM:false, url:"OperationLog", roles:["GroupManager","GroupFinance"]},
            { name: "权限管理", showM:false, url:"PrivilegeManagement", roles:["SchoolManager"]}
          ]
        },
        {
          name: "缴费方案&缴费操作",
          list: [
            { name: "补录", showM:false, url: "Supplement", roles:["SchoolFinance"]},
            { name: "退费", showM:false, url: "Refund", roles:["SchoolFinance"]},
            { name: "冲正", showM:false, url: "Rectification", roles:["SchoolFinance"]}
          ]
        },
        {
          name: "报表&其他",
          list: [
            { name: "应收报表", showM:false, url:"receivableReportForm", roles:["GroupManager","SchoolFinance","GroupFinance"]},
            { name: "实收报表", showM:false, url:"netReceiptsReportForm", roles:["GroupManager","SchoolFinance","GroupFinance"]},
            { name: "欠缴报表", showM:false, url:"arrearsReportForm", roles:["GroupManager","SchoolFinance","GroupFinance"]},
            { name: "退费报表", showM:false, url:"refundReportForm", roles:["GroupManager","SchoolFinance","GroupFinance"]},
            { name: "减免", showM:false, url:"Deduction", roles:["SchoolFinance"]},
            { name: "需缴纳学生列表", showM:false, url:"ListOfPayingStudents", roles:["GroupManager","SchoolFinance","GroupFinance"]},
            { name: "特训费实收报表", showM:false, url:"NetReceiptsSpecialTraining", roles:["GroupManager","SchoolFinance","GroupFinance"]},
            { name: "特训费退费报表", showM:false, url:"RefundSpecialTraining", roles:["GroupManager","SchoolFinance","GroupFinance"]},

            { name: "月报表（缴费类型）", showM:false, url:"PaymentItems", roles:["SchoolFinance","GroupFinance"]},
            { name: "月报表（支付方式）", showM:false, url:"PaymentMethod", roles:["SchoolFinance","GroupFinance"]}
            //{ name: "缴费人数统计表", showM:false, url:"PopulationStatistics", roles:["SchoolFinance","GroupFinance"]}


            // { name: "特训费报表", showM:false, url:"SpecialTrainingFeeStatement", roles:["GroupManager","SchoolFinance","GroupFinance"]}
          ]
        }
      ]
    };
  },
  mounted() {
    this.setFirst()


  },
  methods: {
    // TODO: 进入目录
    intoAddress:function(r){
      this.$router.push({name:r.url});
    },
    // 初次进入
    setFirst(){
      let that = this;
      setTimeout(function(){
        that.setMenu();
      },500)
    },
    // TODO: 设置目录权限
    setMenu(){
      for(let a of this.dataList){
        for(let b of a.list){
          for(let c of b.roles){
             if(this.$store.state.userModule.roleList.indexOf(c)>-1){
                b.showM = true;
              }
          }
        }
      }

      console.log(this.dataList);
    }
  }
};
</script>

<style>
</style>
